package com.weimob.learn.springbootdubbo.config;

import com.alibaba.dubbo.config.*;
import org.springframework.context.annotation.Bean;

/**
 * @program: xh-learn-record
 * @description:
 * @author: sch
 * @create: 2023-02-01 15:44
 **/
//@Configuration
public class DubboConfig {
    @Bean
    public ApplicationConfig dubboApplication() {
        ApplicationConfig applicationConfig = new ApplicationConfig();
        applicationConfig.setName("springboot-dubbo-demo");
        applicationConfig.setOwner("xhx");
        return applicationConfig;
    }

    @Bean
    public ProtocolConfig dubboProtocol() {
        ProtocolConfig protocolConfig = new ProtocolConfig();
        protocolConfig.setName("dubbo");
        protocolConfig.setPort(20885);
        return protocolConfig;
    }

    @Bean
    public RegistryConfig dubboRegistry() {
        RegistryConfig registryConfig = new RegistryConfig();
        registryConfig.setAddress("zookeeper://10.11.32.251:2181?backup=10.11.32.102:2181,10.11.33.139:2181");
        return registryConfig;
    }

    @Bean
    public MonitorConfig dubboMonitory() {
        MonitorConfig monitorConfig = new MonitorConfig();
        monitorConfig.setProtocol("registry");
        monitorConfig.setAddress("local-log-log4j");
        return monitorConfig;
    }

    @Bean
    public ProviderConfig dubboProvider() {
        ProviderConfig providerConfig = new ProviderConfig();
        providerConfig.setTimeout(10000);
        providerConfig.setThreads(400);
        providerConfig.setRegister(true);
        providerConfig.setRetries(0);
        return providerConfig;
    }

    @Bean
    public ConsumerConfig dubboConsumer() {
        ConsumerConfig consumerConfig = new ConsumerConfig();
        consumerConfig.setTimeout(10000);
        consumerConfig.setRetries(0);
        consumerConfig.setCheck(Boolean.FALSE);
        return consumerConfig;
    }
}
